//1.导入
import axios from 'axios'
import auth from '@/tools/auth.js'

//var baseURL = "http://chenhaisen.xiaomy.net/note-spring";
  var baseURL = "http://114.132.64.216:8888";

//2.创建axios实例
const axiosInstance = axios.create({
    baseURL: baseURL,//前置URL地址
    timeout:500000 //请求超时时间
})

//3.定义拦截器
//添加请求拦截器
axiosInstance.interceptors.request.use(function (config) {
    //在发送请求之前，把JWT令牌放入头信息"Authorzation"
    config.headers.Authorization = auth.getToken();
    return config;
},function (error) {
    //对请求错误做些什么
    return Promise.reject(error);
});

//4.导出
export { axiosInstance, baseURL };